package org.jeecg.modules.monitoring.j_monitoring.service.impl;

import org.apache.ibatis.annotations.Param;
import org.jeecg.modules.monitoring.j_monitoring.entity.EquipmentData;
import org.jeecg.modules.monitoring.j_monitoring.entity.EquipmentItem;
import org.jeecg.modules.monitoring.j_monitoring.entity.MCabinet;
import org.jeecg.modules.monitoring.j_monitoring.mapper.MCabinetMapper;
import org.jeecg.modules.monitoring.j_monitoring.service.IMCabinetService;
import org.jeecg.modules.monitoring.j_monitoring.vo.MCabinetDevice;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import java.util.List;

/**
 * @Description: 机柜
 * @Author: xiaoyq
 * @Date:   2023-02-22
 * @Version: V1.0
 */
@Service
public class MCabinetServiceImpl extends ServiceImpl<MCabinetMapper, MCabinet> implements IMCabinetService {

    public List<EquipmentItem> getEquipmentAllList(String id){
        return baseMapper.getEquipmentAllList(id);
    }

    @Override
    public List<MCabinetDevice> getDeviceListByIds(List<String> idList) {
        return baseMapper.getDeviceListByIds(idList);
    }

    /**
     * 根据机房名称统计机柜数量
     * @param room
     * @return
     */
    @Override
    public Integer getCabinetCountByRoom(@Param("room")String room){
        return baseMapper.selectCabinetCountByRoom(room);
    }

    /**
     * 根据机房名称统计空调数量
     * @param room
     * @return
     */
    @Override
    public Integer getAirCountByRoom(@Param("room")String room){
        return baseMapper.selectAirCountByRoom(room);
    }

    public String getId(String name,List<MCabinet> mCabinetList){
        for (MCabinet cabinet : mCabinetList){
            if (name.equals(cabinet.getName())){
                return cabinet.getId();
            }
        }
        return "";
    }

}
